import { Controller, Post, Body, UseGuards, Get, Query  ,UseInterceptors } from '@nestjs/common';
import { ChildCareService } from './chid-care.service';
import { CreateChildDto } from '../dto';
import { JwtAuthGuard } from '../../auth/jwt-auth.guard';
import { UserId } from '../../decorators/user.decorator';
import { GrowthRecord } from '@prisma/client';
import { TransformDateInterceptor } from '../../interceptors/transform-date.interceptor';

@UseInterceptors(TransformDateInterceptor)
@Controller('child')
@UseGuards(JwtAuthGuard)
export class ChildCareController {
    constructor(private readonly childCareService: ChildCareService) {}

    @Post()
    create(@Body() createChildDto: CreateChildDto, @UserId() userId: number) {
        return this.childCareService.create(createChildDto, userId);
    }
   
    @Get()
    findAll(@Query() query: { id?: number }, @UserId() userId: number): Promise<GrowthRecord[]> {
     return this.childCareService.findAll(query, userId);
   }

}
